<?php
/**
 * Created by Dumitru Russu.
 * User: developer
 * Date: 11/13/12
 * Time: 4:23 PM
 * To change this template use File | Settings | File Templates.
 */
class Page_Fe_Products_Tags extends Page {

	function __construct() {
		self::$TPL->appendJsFile('problems_reported');
		self::$TPL->appendJsFile('category');
		self::$TPL->appendCssFile('category');
		parent::__construct();
	}

	public function defaultAction() {
		if (self::$P) {
			$currentPage = self::$P;
		} else if ($paginationNumber = self::$PAGE['pp_pagination_number']) {
			$currentPage = $paginationNumber;
		} else {
			$currentPage = 1;
		}
		self::$TPL->assign('currentPage', $currentPage);
		$paginations = Db_Cms_Pages::getPaginationUrlsByPage(self::$PAGE, $currentPage);
		self::$TPL->assign('paginations', $paginations);

		$sessionProductTheme = self::$S->Get('sessionProductTheme');
		self::$TPL->assign('sessionProductTheme', $sessionProductTheme);

		$totalPaginations = count($paginations);
		self::$TPL->assign('totalPaginations', $totalPaginations);
		self::$TPL->assign('filePath', self::$PROJECT['pr_resources_live']);

		self::$TPL->setBodyTemplate('show_products_by_tag');
		return array(
			'type' => 'display'
		);
	}

	public function ajaxAddToWishlistAction() {
		$productId = post('productId', 'int');
		$memoryIdentifier = post('memoryListId', 'string');
		$themeId = post('themeId', 'int');
		$result = false;
		if ($productId && $memoryIdentifier && $themeId) {
			$memoryList = new Db_Products_MemoryList();
			$result = $memoryList->addProductToMemoryList($productId, $memoryIdentifier, $themeId);
		}
		return array(
			'type' => 'encoded_json',
			'content' => json_encode($result)
		);
	}
}
